package com.hotel.homehotel.before.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hotel.homehotel.before.entiy.Order;
import com.hotel.homehotel.before.entiy.vo.RoomVo;
import com.hotel.homehotel.before.mapper.OrderMapper;
import com.hotel.homehotel.before.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    OrderMapper orderMapper;
    public List<Order> getAllOrders(){
        QueryWrapper<Order> queryWrapper=new QueryWrapper();
        return orderMapper.selectList(queryWrapper);
    }
    public  boolean insertOrder(Order order){
        return orderMapper.insert(order)>0;
    }
    public  boolean  deleteOrder(String id){
        return  orderMapper.deleteById(id)>0;
    }
    public  boolean  updateOrder(Order order){
        return orderMapper.updateById(order)>0;
    }
    public Order getOrderById(String id){
        return orderMapper.selectById(id);
    }
    public List<RoomVo> selectTime(String id){
        return orderMapper.selectTime(id);
    }
    public List<Order> getAllOrdersByUid(String uid){
       QueryWrapper<Order> queryWrapper=new QueryWrapper();
       queryWrapper.eq("user_id",uid);
        return  orderMapper.selectList(queryWrapper);
    }
}
